package com.zjm.servlet.servlet03_three_ways;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author ZJM
 * @date 2024/4/11 22:13
 * 方式1：直接实现javax.servlet.Servlet接口
 * <p>
 * 实现接口中的所有方法，包括init()、service()和destroy()等。
 */
public class Way01Servlet implements Servlet {

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        servletResponse.setContentType("text/html;charset=UTF-8");
        PrintWriter out = servletResponse.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + "方式1：直接实现javax.servlet.Servlet接口" + "</h1>");
        out.println("</body></html>");
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
